Table of contents
Installation
You need to install package.
npm install combo-storage
Getting started
You should import the required storages to use the package
import { LocalStorage, SeessionStorage, Cookie } from 'combo-storage'
Then use the methods of storage. For example:
LocalStorage.set('user', 'awibox');
Base methods for LocalStorage and SessionStorage
set
LocalStorage.set(key, value);
SessionStorage.set(key, value);
get
LocalStorage.get(key);
SessionStorage.get(key);
remove
LocalStorage.remove(key);
SessionStorage.remove(key);
сlear
LocalStorage.clear();
SessionStorage.clear();
Additional methods for LocalStorage and SessionStorage
You can now save objects and arrays
setObject
var object = {
id: 1,
value: 'object'
};
LocalStorage.setObject(key, object);
SessionStorage.setObject(key, object);
getObject
LocalStorage.getObject(key);
SessionStorage.getObject(key);
Cookie methods
set
var options = {
path: '/',
expires: Date(),
'max-age': 3600,
secure: true,
domain: 'domain.com'
};
Cookie.set(name, value, options);
get
Cookie.get(name)
remove
Cookie.remove(name)